<!--工作经历表单-->
<template>
  <div class="form">
    <yd-cell-group>
      <yd-cell-item>
        <span slot="left" class="label required">工作开始日期</span>
        <xf-date-picker
          :valid="[{required: true, msg: '请选择工作开始日期'}]"
          v-model="form.aae030"
          ref="aae030"
          placeholder="请选择工作开始日期"
          :endDate="new Date()"
          slot="right"></xf-date-picker>
      </yd-cell-item>
      <yd-cell-item>
        <span slot="left" class="label required">工作结束日期</span>
        <xf-date-picker
          :valid="[{required: true, msg: '请选择工作结束日期'}]"
          v-model="form.aae031"
          ref="aae031"
          placeholder="请选择工作结束日期"
          :endDate="new Date()"
          slot="right"></xf-date-picker>
      </yd-cell-item>
      <yd-cell-item>
        <span slot="left" class="label required">所在工作单位名称</span>
        <xf-input
          slot="right"
          :valid="[{required: true, msg: '请输入所在工作单位名称'}]"
          v-model="form.aac045"
          ref="aac045"
          placeholder="请输入所在工作单位名称"></xf-input>
      </yd-cell-item>
      <yd-cell-item>
        <span slot="left" class="label required">从事工作或担任职务</span>
        <xf-input
          slot="right"
          :valid="[{required: true, msg: '请输入从事工作或担任职务'}]"
          v-model="form.aac0b3"
          ref="aac0b3"
          placeholder="请输入从事工作或担任职务"></xf-input>
      </yd-cell-item>
      <yd-cell-item>
        <span slot="left" class="label">单位证明人</span>
        <xf-input
          slot="right"
          v-model="form.aacb01"
          ref="aacb01"
          placeholder="请输入单位证明人"></xf-input>
      </yd-cell-item>
    </yd-cell-group>
    <div class="right-bottom">
      <mt-button type="default" size="small" @click="cancel">取消</mt-button>
      <mt-button type="primary" size="small" @click="onSubmit">保存</mt-button>
    </div>
  </div>
</template>
<script>
  import XfDatePicker from '../../../components/xf-date-picker/xf-date-picker.vue'
  import XfInput from '../../../components/xf-input/xf-input.vue'
  import {echo, validate} from '../../../common/js/util'
  import {mapGetters} from 'vuex'

  export default {
    props: {
      detail: {type: null, default: () => { return {} }}
    },
    components: {
      XfInput,
      XfDatePicker},
    name: 'form-work',
    computed: {
      ...mapGetters([
        'userInfo'
      ])
    },
    data() {
      return {
        form: {
          aac0b0: '', // 编号
          personId: this.$route.query.id,
          aae030: '', // 开始时间
          aae031: '', // 结束时间
          aac045: '', // 内容
          aac0b3: '', // 从事内容
          aacb01: '' // 证明人
        }
      }
    },
    methods: {
      cancel() {
        this.$emit('cancel')
      },
      onSubmit() {
        validate.bind(this)(this.form).then(() => {
          const form = Object.assign({}, this.form)
          this.$post('/admin/person/sapi/personal/records/perEntry/update/work/expace', form, loading => {
            this.$message.loading(loading)
          }).then(res => {
            this.$emit('save')
          })
        })
      }
    },
    created() {
      echo(this.form, this.detail)
    }
  }
</script>
